package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YxDeviceNoticeMessage;
import com.ruoyi.system.service.IYxDeviceNoticeMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备通知消息Controller
 * 
 * @author lingyu
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/system/deviceNoticeMessage")
public class YxDeviceNoticeMessageController extends BaseController
{
    @Autowired
    private IYxDeviceNoticeMessageService yxDeviceNoticeMessageService;

    /**
     * 查询设备通知消息列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceNoticeMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(YxDeviceNoticeMessage yxDeviceNoticeMessage)
    {
        startPage();
        List<YxDeviceNoticeMessage> list = yxDeviceNoticeMessageService.selectYxDeviceNoticeMessageList(yxDeviceNoticeMessage);
        return getDataTable(list);
    }

    /**
     * 导出设备通知消息列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceNoticeMessage:export')")
    @Log(title = "设备通知消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YxDeviceNoticeMessage yxDeviceNoticeMessage)
    {
        List<YxDeviceNoticeMessage> list = yxDeviceNoticeMessageService.selectYxDeviceNoticeMessageList(yxDeviceNoticeMessage);
        ExcelUtil<YxDeviceNoticeMessage> util = new ExcelUtil<YxDeviceNoticeMessage>(YxDeviceNoticeMessage.class);
        util.exportExcel(response, list, "设备通知消息数据");
    }

    /**
     * 获取设备通知消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceNoticeMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yxDeviceNoticeMessageService.selectYxDeviceNoticeMessageById(id));
    }

    /**
     * 新增设备通知消息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceNoticeMessage:add')")
    @Log(title = "设备通知消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YxDeviceNoticeMessage yxDeviceNoticeMessage)
    {
        return toAjax(yxDeviceNoticeMessageService.insertYxDeviceNoticeMessage(yxDeviceNoticeMessage));
    }

    /**
     * 修改设备通知消息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceNoticeMessage:edit')")
    @Log(title = "设备通知消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YxDeviceNoticeMessage yxDeviceNoticeMessage)
    {
        return toAjax(yxDeviceNoticeMessageService.updateYxDeviceNoticeMessage(yxDeviceNoticeMessage));
    }

    /**
     * 删除设备通知消息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceNoticeMessage:remove')")
    @Log(title = "设备通知消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yxDeviceNoticeMessageService.deleteYxDeviceNoticeMessageByIds(ids));
    }
}
